package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelCommentTravelType;
import com.ktgj.hotel.service.IHotelCommentTravelTypeService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 出行类型Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/ravelType")
public class HotelCommentTravelTypeController extends BaseController
{
    @Autowired
    private IHotelCommentTravelTypeService hotelCommentTravelTypeService;

    /**
     * 查询出行类型列表
     */
    @PreAuthorize(hasPermi = "hotel:type:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelCommentTravelType hotelCommentTravelType)
    {
        startPage();
        List<HotelCommentTravelType> list = hotelCommentTravelTypeService.selectHotelCommentTravelTypeList(hotelCommentTravelType);
        return getDataTable(list);
    }

    /**
     * 导出出行类型列表
     */
    @PreAuthorize(hasPermi = "hotel:type:export")
    @Log(title = "出行类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelCommentTravelType hotelCommentTravelType) throws IOException
    {
        List<HotelCommentTravelType> list = hotelCommentTravelTypeService.selectHotelCommentTravelTypeList(hotelCommentTravelType);
        ExcelUtil<HotelCommentTravelType> util = new ExcelUtil<HotelCommentTravelType>(HotelCommentTravelType.class);
        util.exportExcel(response, list, "出行类型数据");
    }

    /**
     * 获取出行类型详细信息
     */
    @PreAuthorize(hasPermi = "hotel:type:query")
    @GetMapping(value = "/{traveltypeid}")
    public AjaxResult getInfo(@PathVariable("traveltypeid") Long traveltypeid)
    {
        return AjaxResult.success(hotelCommentTravelTypeService.selectHotelCommentTravelTypeById(traveltypeid));
    }

    /**
     * 新增出行类型
     */
    @PreAuthorize(hasPermi = "hotel:type:add")
    @Log(title = "出行类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelCommentTravelType hotelCommentTravelType)
    {
        return toAjax(hotelCommentTravelTypeService.insertHotelCommentTravelType(hotelCommentTravelType));
    }

    /**
     * 修改出行类型
     */
    @PreAuthorize(hasPermi = "hotel:type:edit")
    @Log(title = "出行类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelCommentTravelType hotelCommentTravelType)
    {
        return toAjax(hotelCommentTravelTypeService.updateHotelCommentTravelType(hotelCommentTravelType));
    }

    /**
     * 删除出行类型
     */
    @PreAuthorize(hasPermi = "hotel:type:remove")
    @Log(title = "出行类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{traveltypeids}")
    public AjaxResult remove(@PathVariable Long[] traveltypeids)
    {
        return toAjax(hotelCommentTravelTypeService.deleteHotelCommentTravelTypeByIds(traveltypeids));
    }
}
